﻿using Engine.Graphics;
using Engine;
using Game;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Game
{
    public abstract class 方块模板 : Block
    {
        public Texture2D m_texture;

        public string m_texturename;

        public Color m_color;

        public 方块模板(string texturename, Color color)
        {

            m_texturename = texturename;
            m_color = color;
        }

        public override void Initialize()
        {
            m_texture = ContentManager.Get<Texture2D>(m_texturename, (string)null);
        }

        public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z)
        {
            generator.GenerateCubeVertices(this, value, x, y, z, Color.White, geometry.GetGeometry(this.m_texture).OpaqueSubsetsByFace);
        }

        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {

            BlocksManager.DrawCubeBlock(primitivesRenderer, value, new Vector3(size), ref matrix, m_color, m_color, environmentData, m_texture);
        }

      

        public override int GetFaceTextureSlot(int face, int value)
        {
            switch (face)
            {
                case 0:
                case 1:
                case 2:
                case 3:
                    return 0; // 对于face为0到3的情况，返回0  
                case 4:
                case 5:
                    return 1; // 对于face为4或5的情况，返回1  
                default:
                    return 0; // 对于其他所有情况，返回0  
            }
        }
    }
}
